import JsCookie from "js-cookie";
import * as uuid from "uuid";

export const getCookie = JsCookie.get;

export const setCookie = JsCookie.set;

export const removeCookie = JsCookie.remove;

/**
 * 清除所有cookie函数
 */
export const clearAllCookie: () => void = (extraKeys: string[] = []) => {
  const keys = document.cookie.match(/[^ =;]+(?==)/g) || [];

  [...keys, ...extraKeys].forEach((key: string) => {
    removeCookie(key);
  });
};

export const getUuid: () => string = () => uuid.v4();
